<html>
<head><meta charset="utf-8"><title>Permanently unstable features for use in tests? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html">Permanently unstable features for use in tests?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213727935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213727935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213727935">(Oct 18 2020 at 21:50)</a>:</h4>
<p>I'm trying to work on <a href="https://github.com/rust-lang/rust/issues/69399">#69399</a>, but I'm having trouble finding any const-related features I can use in a test that won't become stable in the future.</p>



<a name="213728202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213728202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213728202">(Oct 18 2020 at 21:57)</a>:</h4>
<p>Specifically, I need to craft a function</p>
<div class="codehilite"><pre><span></span><code>#[allow_internal_unstable(&lt;feature&gt;)]
const fn bar() {
    &lt;body using feature&gt;
}
</code></pre></div>


<p>Which will compile only if the <code>allow_internal_unstable</code> actually enables the feature. <code>llvm_asm</code> works for non-const contexts, but I need one for const.</p>



<a name="213728272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213728272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213728272">(Oct 18 2020 at 21:59)</a>:</h4>
<p>I think library features don't use a central registry, so you might be able to just define a custom <code>#[unstable] const fn</code> inside the test</p>



<a name="213729635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213729635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213729635">(Oct 18 2020 at 22:33)</a>:</h4>
<p>I tried that, but I got a message "stability attributes may not be used outside of the standard library". Is there a way around that?</p>



<a name="213729708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213729708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213729708">(Oct 18 2020 at 22:35)</a>:</h4>
<p>They are behind another unstable feature, you should be able to enable that</p>



<a name="213730028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213730028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213730028">(Oct 18 2020 at 22:44)</a>:</h4>
<p>Do you know which one? Having trouble finding it. Tried <code>rustc_attrs</code> but that doesn't seem to be it</p>



<a name="213730256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213730256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213730256">(Oct 18 2020 at 22:51)</a>:</h4>
<p>Ah, <code>staged_api</code></p>



<a name="213731538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Permanently%20unstable%20features%20for%20use%20in%20tests%3F/near/213731538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Jaszkowiak <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Permanently.20unstable.20features.20for.20use.20in.20tests.3F.html#213731538">(Oct 18 2020 at 23:28)</a>:</h4>
<p>It looks like the feature is working, but now I can't toggle it on. <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f200c82a547055c4f1531d6e6bae467c">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f200c82a547055c4f1531d6e6bae467c</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>